{% extends "base.html" %}
{% load static %}
{% block add_css %}
    {{ block.super }}

    <link rel="stylesheet" href="{% static "easymde/dist/easymde.min.css" %}">
{% endblock %}
{% block add_styles %}
    {{ block.super }}
    .editor-toolbar, .editor-statusbar, .editor-preview-side, .CodeMirror {
    width: 70% !important;
    }
    .chosen-container.chosen-container-multi {
    width: 70% !important;
    }
{% endblock %}
{% block content %}
    {{ block.super }}
    <form class="form-horizontal" action="{% url 'add_engagement_presets' pid %}" method="post">{% csrf_token %}
     {% include "dojo/form_fields.html" with form=tform %}
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <input class="btn btn-primary" type="submit" value="Submit"/>
            </div>
        </div>
    </form>
{% endblock %}
{% block postscript %}
    {{ block.super }}
    <script type="application/javascript" src="{% static "easymde/dist/easymde.min.js" %}"></script>
    <script type="application/javascript">
        $(function () {
            $("textarea").each(function (index, elem) {
                if (elem.hasAttribute("required")) {
                    elem.removeAttribute("required");
                    elem.id = "req"
                }
                
                if(!$(elem).hasClass('select2-search__field')) {
                    var mde = new EasyMDE({
                        spellChecker: false,
                        inputStyle: "contenteditable",
                        element: elem,
                        autofocus: false,
                        forceSync: true,
                        toolbar: ["bold", "italic", "heading", "|",
                            "quote", "unordered-list", "ordered-list", "|",
                            "link", "image", "|",
                            "table", "horizontal-rule", "code", "|",
                            "guide"
                        ]
                    });
                    mde.render();
                }
            });
        });
    </script>
{% endblock %}
